﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RaytracerLib.MathLib;
using RaytracerLib.Layers;
using RaytracerLib.Layers.OverlayCorrectors;

namespace RaytracerLib.Layers.Interpolators
{
    public abstract class Interpolator
    {
        protected ArrayBase m_array;
        public OverlayCorrector OverlayCorrector { get; private set; }

        public static Interpolator Create(ArrayBase a_array)
        {
            if (a_array.InterpolationMethod == InterpolationMethod.Bicubic)
                return new BicubicInterpolator(a_array);
            else if (a_array.InterpolationMethod == InterpolationMethod.Bilinear)
                return new BilinearInterpolator(a_array);
            else if (a_array.InterpolationMethod == InterpolationMethod.NearestNeighbour)
                return new NearestNeighbourInterpolator(a_array);
            else
                throw new InvalidOperationException();
        }

        protected Interpolator(ArrayBase a_array)
        {
            m_array = a_array;
            OverlayCorrector = OverlayCorrector.Create(
                a_array.OverlayMethod, a_array.Width, a_array.Height, 2);
        }

        public abstract ColorFloat InterpolateColor(double a_x, double a_y);
        public abstract double InterpolateValue(double a_x, double a_y);
    }
}
